#include "GameMain.h"

static GameMain *gameMain = NULL;
CCScene *scene;
GameBgLayer *bgLayer;
CCLayer *uiLayer;
CCLayer *heroLayer;
CCLayer *buttonLayer;
CCLayer *errorLayer;
GameMainButton *button;
GameGridLayer *grid;
void GameMain::init()
{
	do
	{
		scene = CCScene::create();
		CC_BREAK_IF(!scene);
		CCDirector::sharedDirector()->runWithScene(scene);

		bgLayer = GameBgLayer::create();
		scene->addChild(bgLayer);
		bgLayer->setPosition(CCPointZero);

		heroLayer = CCLayer::create();
		CC_BREAK_IF(!heroLayer);
		scene->addChild(heroLayer);
		heroLayer->setPosition(CCPointZero);

		grid = GameGridLayer::create();
		scene->addChild(grid);
		grid->setPosition(CCPointZero);

		buttonLayer = CCLayer::create();
		CC_BREAK_IF(! buttonLayer);
		scene->addChild(buttonLayer);
		buttonLayer->setPosition(CCPointZero);

		uiLayer = CCLayer::create();
		CC_BREAK_IF(! uiLayer);
		scene->addChild(uiLayer);		
		uiLayer->setPosition(CCPointZero);

		errorLayer = CCLayer::create();
		CC_BREAK_IF(! errorLayer);
		scene->addChild(errorLayer);
		errorLayer->setPosition(CCPointZero);

		button = new GameMainButton();
		button->init();


	}while(0);
}

CCScene *GameMain::getScene()
{
	return scene;
}

GameBgLayer *GameMain::getBgLayer()
{
	return bgLayer;
}

CCLayer *GameMain::getHeroLayer()
{
	return heroLayer;
}

GameGridLayer *GameMain::getGridLayer()
{
	return grid;
}

CCLayer *GameMain::getUiLayer()
{
	return uiLayer;
}

CCLayer *GameMain::getButtonLayer()
{
	return buttonLayer;
}

CCLayer *GameMain::getErrorLayer()
{
	return errorLayer;
}

GameMain *GameMain::sharedGameMain()
{
	if(gameMain == NULL)
		gameMain = new GameMain();
	return NULL;
}